﻿#define _CRT_SECURE_NO_WARNINGS 1

# include<stdio.h>
# include<math.h>

void q1()
{
	int count = 0;
	for (int i = 1; i < 5; ++i)
	{
		for (int j = 1; j < 5; ++j)
		{
			for (int k = 1; k < 5; ++k)
			{
				if (i != j && i != k && j != k)
				{
					printf("%d%d%d ", i, j, k);
					++count;
				}
			}
		}
	}
	printf("\n总计：%d\n", count);
}

void q2()
{
	const double rate[] = { 0.1,0.075,0.05,0.03,0.015,0.01 };
	int i = 0;
	scanf("%d", &i);
	i /= 10000.0;  // 单位：万元
	double ret = 1.0;
	// 档位：10 20 40 60 100
	if (i <= 10)
		ret = i * rate[0];
	else if (i <= 20)
		ret = 10 * rate[0] + (i - 10) * rate[1];
	else if (i <= 40)
		ret = 10 * rate[0] + 10 * rate[1]
		+ (i - 20) * rate[2];
	else if (i <= 60)
		ret = 10 * rate[0] + 10 * rate[1]
		+ 20 * rate[2] + (i - 40) * rate[3];
	else if (i <= 100)
		ret = 10 * rate[0] + 10 * rate[1]
		+ 20 * rate[2] + 20 * rate[3]
		+ (i - 60) * rate[4];
	else
		ret = 10 * rate[0] + 10 * rate[1]
		+ 20 * rate[2] + 20 * rate[3]
		+ 40 * rate[4] + (i - 100) * rate[5];
	printf("%.2lf万元\n", ret);
}


void q3()
{
	const int dis1 = 100;
	const int dis2 = 268;
	for (int i = 0; i < 99999999; ++i)
	{
		int x = sqrt(i + dis1);
		int y = sqrt(i + dis2);
		if ((x * x == i + dis1) && (y * y == i + dis2))
		{
			printf("%d\n", i);
		}
	}
}

int GetMonthDay(int year, int month)
{
	int monthDay[13] = { -1,31,28,31,30,31,30,31,31,30,31,30,31 };
	if (month == 2
		&& ((year % 4 == 0 && year % 100 != 0)
			|| (year % 400 == 0)))
	{
		return 29;
	}
	return monthDay[month];
}

void q4()
{
	int year, month, day;
	scanf("%d %d %d", &year, &month, &day);
	int ret = 0;
	for (int i = 1; i < month; ++i)
	{
		ret += GetMonthDay(year, i);
	}
	ret += day;
	printf("%d\n", ret);
}

void q5()
{
	int x, y, z;
	scanf("%d %d %d", &x, &y, &z);
	int sum = x + y + z;
	int min = x;
	min = min < y ? min : y;
	min = min < z ? min : z;
	int max = x;
	max = max > y ? max : y;
	max = max > z ? max : z;
	printf("%d %d %d\n", min, sum - min - max, max);
}

void q6()
{
	printf("  ****\n");
	printf(" *\n");
	printf(" *\n");
	printf(" *\n");
	printf("  ****\n");
}

# include<windows.h>
void q7()
{
	SetConsoleOutputCP(437);
	char a = 176, b = 219;
	printf("%c%c%c%c%c\n", b, a, a, a, b);
	printf("%c%c%c%c%c\n", a, b, a, b, a);
	printf("%c%c%c%c%c\n", a, a, b, a, a);
	printf("%c%c%c%c%c\n", a, b, a, b, a);
	printf("%c%c%c%c%c\n", b, a, a, a, b);
}

void q8()
{
	for (int i = 1; i < 10; ++i)
	{
		for (int j = 1; j <= i; ++j)
		{
			printf("%d*%d=%d\t", j, i, i * j);
		}
		printf("\n");
	}
}

void q9()
{
	SetConsoleOutputCP(437);
	for (int i = 0; i < 8; i++)
	{
		for (int j = 0; j < 8; j++)
			(i + j) % 2 == 0 ? printf("%c%c", 219, 219) : printf("  ");
		printf("\n");
	}
}

void q10()
{
	printf("\1\1笑\n");/*输出两个笑脸*/
	SetConsoleOutputCP(437);
	for (int i = 1; i < 11; i++)
	{
		for (int j = 1; j <= i; j++)
			printf("%c%c", 219, 219);
		printf("\n");
	}
}


typedef long long ll;
void q11()
{

	ll d1 = 1, d2 = 1;
	printf("从第三个月开始，兔子总数：\n");
	for (int i = 1; i <= 25; i++)
	{
		d1 = d1 + d2;
		d2 = d1 + d2;
		printf("%lld %lld\n", d1, d2);
	}
}

#include<math.h>
void q12()
{
	int count = 0;
	for (int i = 100; i < 201; ++i)
	{
		int flg = 1;
		for (int j = 2; j <= sqrt(i); ++j)
		{
			// 不是素数
			if (i % j == 0)
			{
				flg = 0;
				break;
			}
		}
		if (flg)
		{
			++count;
			printf("%d\t ", i);
			// 每十个一行
			if (!(count % 10))
				printf("\n");
		}
	}
	printf("\n总个数：%d\n", count);
}

#include<stdbool.h>
bool IsWaterFlower(int x)
{
	int sum = 0;
	int ret = x;
	while (x)
	{
		int tmp = x % 10;
		x /= 10;
		sum += tmp * tmp * tmp;
	}
	return sum == ret;
}
void q13()
{
	for (int i = 100; i < 1000; ++i)
	{
		if (IsWaterFlower(i))
		{
			printf("%d ", i);
		}
	}
}

void q14()
{
	int n = 0;
	scanf("%d", &n);
	int i = 2, flg = 0;
	while (n != 1)
	{
		// 一直除以同一个数（可以保证这个数一定是素数）
		while (n % i == 0)
		{
			if (flg)
				printf("*");
			n /= i;
			printf("%d", i);
			flg = 1;
		}
		++i;
	}
	printf("\n");
}

void q15()
{
	int n = 3; // 输入次数
	int sco = 0;
	const char level[3] = { 'A','B','C' };
	while (n--)
	{
		scanf("%d", &sco);
		if (sco >= 90) printf("%c\n", level[0]);
		else if (sco < 60) printf("%c\n", level[2]);
		else printf("%c\n", level[1]);
	}
}

void q16()
{
	int m, n;
	scanf("%d %d", &m, &n);
	int  num1 = m, num2 = n;  // 记录输入的值，求最大公倍数
	int mode = m % n;
	while (mode)
	{
		m = n;
		n = mode;
		mode = m % n;
	}
	printf("最大公约数：%d\n", n);
	printf("最小公倍数：%d\n", num1 * num2 / n);
}

void q17()
{
	int ch_count = 0, num_count = 0,
		space_count = 0, else_count = 0;
	char str[500] = { 0 };
	fgets(str, 100, stdin); // 读取一行字符串，包含空格,换行
	str[strlen(str) - 1] = '\0'; // 将末尾'\n'改为'\0'
	int i = 0;
	// 遇到'\0'停止
	while (str[i] != '\0')
	{
		if ((str[i] >= 'a' && str[i] <= 'z')
			|| (str[i] >= 'A' && str[i] <= 'Z'))
			++ch_count;
		else if (' ' == str[i])
			++space_count;
		else if (str[i] >= '0' && str[i] <= '9')
			++num_count;
		else
			++else_count;
		++i;
	}
	printf("字母：%d, 数字：%d, 空格：%d, 其他：%d\n",
		ch_count, num_count, space_count, else_count);
}

void q18()
{
	int a, n;
	scanf("%d %d", &a, &n);
	int sum = 0;
	while (n)
	{
		sum += a * n;
		a *= 10;
		--n;
	}
	printf("%d", sum);
}

# include<math.h>
void q19()
{
	for (int j = 1; j < 1001; ++j)
	{
		int n = j;
		int arr[100] = { 0 };
		int index = 0, sum = 0;
		// 找所有的因子
		for (int i = 1; i <= n / 2; ++i)
		{
			if (n % i == 0)
			{
				sum += i;
				arr[index++] = i;
			}
		}
		// 判断完数并输出
		if (sum == n)
		{
			printf("%d是完数. 因子", n);
			for (int i = 0; i < index; ++i)
			{
				printf("%d ", arr[i]);
			}
			printf("\n");
		}
	}
}

void q20()
{
	double height = 100;
	double sum = 100;
	const double rate = 0.5; // 衰减率
	for (int i = 1; i < 10; i++)
	{
		height *= rate;
		sum += 2 * height;
	}
	printf("10次落地总路程：%.4lf\n", sum);
	printf("10次反弹高度：%.4lf\n", height * rate);
}

int main()
{
	//q1();
	//q2();
	//q3();
	//q4();
	//q5();
	//q6();
	//q7();
	//q8();
	//q9();
	//q10();
	//q11();
	//q12();
	//q13();
	//q14();
	//q15();
	//q16();
	//q17();
	//q18();
	//q19();
	q20();
	return 0;
}